package com.gengzi.item.api;



import com.gengzi.item.pojo.SpecGroup;
import com.gengzi.item.pojo.SpecParam;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;


/**
 * @author 董诗攀
 */
@RequestMapping("spec")
public interface SpecificationApi {
    /**
     *根据分类id查询规格参数组
     * @param cid
     * @return
     */
    @GetMapping("groups/{cid}")
    ResponseEntity<List<SpecGroup>> querySpecGroups(@PathVariable("cid") Long cid);

    /**
     * 根据条件查询规格参数
     * @param gid 规格组id
     * @param cid 商品分类id
     * @param generic 是否搜索
     * @param searching 否为通用属性
     * @return 规格参数
     */
    @GetMapping("params")
    List<SpecParam> queryParams(
            @RequestParam(value = "gid", required = false) Long gid,
            @RequestParam(value = "cid", required = false) Long cid,
            @RequestParam(value = "generic", required = false) Boolean generic,
            @RequestParam(value = "searching", required = false) Boolean searching
    );

    /**
     * 查询规格参数组，及组内参数
     * @param cid
     * @return
     */
    @GetMapping("{cid}")
    List<SpecGroup> querySpecsByCid(@PathVariable("cid") Long cid);
}
